package com.homson.coreservice.serviceinfrastructure.datasource.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.homson.coreservice.servicecommon.enumeration.ValidStatus;
import com.homson.coreservice.servicecommon.utils.EnumUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author: homson_leo
 * @contact: hey_超级巨星（Homson_Leo）- 刘泓岑 1196816884@qq.com
 * @time: 2025/10/3 11:22 AM
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public abstract class BaseModel implements Serializable {
    
    @TableId(type = IdType.AUTO)
    private Long id;
    
    // 数据状态
    private String status;
    
    private LocalDateTime createdAt;
    
    private LocalDateTime updatedAt;
    
    public ValidStatus findStatus() {
        return EnumUtils.of(ValidStatus.class, this.status).orElse(ValidStatus.NA);
    }
    
    public void updateTime() {
        this.updatedAt = LocalDateTime.now();
    }
    
    public void createTime() {
        this.createdAt = LocalDateTime.now();
    }
}
